package com.changhong.framework.sdfs.namenode.server.builder;

import com.changhong.framework.sdfs.namenode.server.exception.NameNodeException;
import com.google.inject.Guice;

/**
 * 默认实现依赖注入
 * @author Summer
 */
public class DefaultInjector implements Injector{
    private com.google.inject.Injector m_injector;

    public DefaultInjector(){
        try {
            m_injector = Guice.createInjector(new NameNodeModules());
        } catch (Throwable ex) {
            NameNodeException exception = new NameNodeException("不能加载 Guice Injector!", ex);
            throw exception;
        }
    }


    @Override
    public <T> T getInstance(Class<T> clazz) {
        return m_injector.getInstance(clazz);
    }

}
